home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 2.6 KB | 56 lines | [TEXT/GEOL] |
- Item 4911385 1-Aug-90 15:12PDT
-
- From: PILLAR.CORP Pillar, Chris Ovard,PRT
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: Failing in PoseModally
-
- Dear MacAppers:
- No one likes to face failure on a daily basis, but ... Lately we've been
- testing our program in low memory conditions, and were wondering if the failure
- handling in TDialogView.PoseModally is as robust as it should be.
- PROCEDURE HdlPoseModally(error: OSErr; message: LONGINT);
- BEGIN
- IF error = noErr THEN
- GOTO 1 { If no error then keep the dialog running }
- ELSE
- BEGIN
- fDismissed := TRUE; { Avoid validating selected edit text }
- itsWindow.Close; { If an error then close the dialog and exit
- via failure mechanism }
- END;
- END;
- This handler jumps back into PoseModally for the case of "error = noErr"
- (usually means that CanDismiss was False when called from Dismiss Dialog), but
- otherwise closes the window and passes the failure up to the next handler. I
- see two problems with this failure handler. The first is mostly my opinion on
- how the failure should be presented to the user. The second is how one can
- programmatically recover from this failure.
-
- First, as a user, when I get a failure in a modal dialog, I don't expect
- the dialog to be closed, rather I expect to get an alert and continue on in the
- same dialog. This could be accomplished by the following failure handler:
- PROCEDURE RecoverPoseModally(error: OSErr; message: LongInt);
- BEGIN
- IF (error <> noErr) THEN
- gApplication.ShowError(error, message);
- GOTO 1;
- END;
- I realize that the call to ShowError can fail, but if that could be magically
- avoided, what problems would be caused by using this handler instead of
- HdlPoseModally?
-
- Second, as a programmer, I don't know what state things will be in after a
- failure in PoseModally. If PoseModally fails in any of the method calls before
- the call to CatchFailures, the failure handler for the method that called
- PoseModally will need to free and/or close the window. If the failure is
- handled by PoseModally, the window has been closed (and freed if
- fFreeOnClosing.) This seems to be inconsistent (a bad quality for failure
- handlers). The above failure handler solves this problem also, because the
- calling method's handler is now ALWAYS responsible for cleaning things up.
-
- If anyone has a better solution or comments on the above I'd be interested
- in hearing from you soon. Thanks.
-
-